﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentManagerApplication.Model
{
    class Grade
    {
        public Grade()
        {

        }

        public Grade(int _id, string _gradename, List<Student> _students,List<Subject> _subjects)
        {
            Id = _id;
            Gradename = _gradename;
            Students = _students;
            Subjects = _subjects;
        }

        private int id;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        private string gradename;

        public string Gradename
        {
            get { return gradename; }
            set { gradename = value; }
        }

        private Profession profession;

        public Profession Profession
        {
            get { return profession; }
            set { profession = value; }
        }

        private List<Student> students;

        public List<Student> Students
        {
            get { return students; }
            set { students = value; }
        }

        private List<Subject> subjects;

        public List<Subject> Subjects
        {
            get { return subjects; }
            set { subjects = value; }
        }

        public List<Student> OrderByStudentScore()
        {
            List<Student> studens = new List<Student>(students.ToArray());
            for (int i = studens.Count; i > 0; i--)
            {
                for (int j = 0; j < i - 1; j++)
                {
                    if (studens[j].SumScore() > studens[j + 1].SumScore())
                    {
                        Student temp = studens[j];
                        studens[j] = studens[j + 1];
                        studens[j + 1] = temp;
                    }
                }
            }
            return studens;
        }
    }
}
